﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using METU_CMT.Business;
using METU_CMT.Business.Google;


namespace METU_CMT
{
    public partial class ExportToGoogleCalendarScreen : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void onBtnExportClicked(object sender, EventArgs e)
        {
            Course _currentCourse = EntityFactory.GetCurrentCourse(UserType.Student);


            try
            {
                GoogleCalendarAdapter _googleCalendarAdapter = new GoogleCalendarAdapter
                                                                       {
                                                                           Email = txtGoogleMail.Text,
                                                                           Password = txtGooglePassword.Text
                                                                       };
                _googleCalendarAdapter.ExportToGoogleCalendar(_currentCourse.Schedule);

                MsgBox1.alert("The schedule is succesfully exported to Google Calendar.");
            }
            catch (Exception ex)
            {
                MsgBox1.alert("Exporting to Google Calendar cannot be completed. An error occured!");
            }
        }

    }
}